clear
capture log close
set more off
use Couples1970

keep statefip metarea age age_m race_m hispan_m educd_m qsex_m qeduc_m agemarr_m marrno_m marrno qage qage_m

keep if qage==0
keep if qage_m==0
keep if qsex_m==0
keep if qeduc_m==0

gen urban=(metarea==0)
gen white_m=(race_m==1&hispan_m==0)
gen black_m=(race_m==2&hispan_m==0)
gen hisp_m=(hispan_m!=0)
gen hs=(educd_m>=60)
gen coll=(educd_m>=100)

gen agediff=age_m-age
gen pos=(agediff>0)
gen agediffpos=agediff*pos
gen agediffneg=agediff*(1-pos)*(-1)
gen ap1=(agediffpos>=2&agediffpos<=4)
gen ap2=(agediffpos>=5&agediffpos<=7)
gen ap3=(agediffpos>=8)
gen an1=(agediffneg>=2&agediffneg<=4)
gen an2=(agediffneg>=5&agediffneg<=7)
gen an3=(agediffneg>=8)

tab age_m, gen(hfe)
gen stfips=urban*100+statefip
tab stfips, gen(stu)

keep if marrno_m==1
gen agem2=agemarr_m*agemarr_m
gen marr2=(marrno==2)
gen marr3=(marrno>=3)

log using Tab3_men_1970_col1col2.log, replace
logit hs ap1 ap2 ap3 an1 an2 an3 agemarr_m agem2 marr2 marr3 white_m black_m hisp_m stu* hfe*, robust
mfx, at(mean ap2=0 ap3=0 an1=0 an2=0 an3=0) varlist(ap1)
mfx, at(mean ap1=0 ap3=0 an1=0 an2=0 an3=0) varlist(ap2)
mfx, at(mean ap1=0 ap2=0 an1=0 an2=0 an3=0) varlist(ap3)
mfx, at(mean ap1=0 ap2=0 ap3=0 an2=0 an3=0) varlist(an1)
mfx, at(mean ap1=0 ap2=0 ap3=0 an1=0 an3=0) varlist(an2)
mfx, at(mean ap1=0 ap2=0 ap3=0 an1=0 an2=0) varlist(an3)

logit coll ap1 ap2 ap3 an1 an2 an3 agemarr_m agem2 marr2 marr3 white_m black_m hisp_m stu* hfe* if hs==1, robust
mfx, at(mean ap2=0 ap3=0 an1=0 an2=0 an3=0) varlist(ap1)
mfx, at(mean ap1=0 ap3=0 an1=0 an2=0 an3=0) varlist(ap2)
mfx, at(mean ap1=0 ap2=0 an1=0 an2=0 an3=0) varlist(ap3)
mfx, at(mean ap1=0 ap2=0 ap3=0 an2=0 an3=0) varlist(an1)
mfx, at(mean ap1=0 ap2=0 ap3=0 an1=0 an3=0) varlist(an2)
mfx, at(mean ap1=0 ap2=0 ap3=0 an1=0 an2=0) varlist(an3)

log close




